#ifndef PARAMSETANDREAD_H
#define PARAMSETANDREAD_H
#include <QWidget>
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTextBrowser>
#include <QLineEdit>
#include <QDebug>
#include <QListWidget>
#include <QListWidgetItem>
#include <QStackedWidget>
#include <QStackedLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QCheckBox>
#include <QTimerEvent>
#include <QTimer>
#include <QProgressBar>
#include "global_var.h"
#include "protocol13761.h"
class ParamSetAndRead: public QWidget
{
Q_OBJECT
public:
    ParamSetAndRead();
    void timerEvent(QTimerEvent *e);
signals:
    void sendframeSignal_param_page();
      void flushPageShow();
public slots:

        void test();
        void paramWriteSlot();
        void paramReadSlot();
        void updatePageShowSlot();
        //报文监控开关 796 _  第16项按钮槽函数
        void  F796_16_clear_choose_Slot();
        //升级相关槽函数
        void update_file_broswer_slot();
        void update_start_slot();
        void update_close_slot();
        void F3ParamRestoreFun();
        void F803ParamRestoreFun();
private:
    protocol13761  protocol376;
    QPushButton  *itemRead,*itemSend;
    QLineEdit *passwordInput;
    QListWidget * paramList;
    QListWidgetItem *param09F1;  //读版本
    QListWidgetItem *paramF3;  //设置IP、端口
    QListWidgetItem *paramF7;  //设置以太网监听参数
    QListWidgetItem *paramF16;  //设置以太网监听参数
    QListWidgetItem *paramF199;  //读取imei iccid
    QListWidgetItem *paramF796Monitor;  //设置F796报文监控
    QListWidgetItem *paramF796MES ; //读取796 mes码。
    QListWidgetItem *paramUpdate ; // 376协议升级
    QListWidgetItem *paramF803 ; // 鸿浩主站第三和第四根连接。
    QListWidgetItem *paramF796MN; //读取796 MN码。
    QListWidgetItem *paramF796ERTUADDR; //读取796 终端地址。
    QListWidgetItem *paramF796VoltageCurrent; //读取796  电压电流倍率。


    QStackedLayout *stack;  //堆栈式窗体
    void (ParamSetAndRead::*PSHOW)( void);

    //读版本09F1
    void param09F1WidgetInit();
    void param09F1WidgetRead();
    void param09F1WidgetShow();
    unsigned char bcd_to_hex(unsigned char data);
    QWidget  *  param09F1Widget;
    QGridLayout  *param09F1GridLayout;
    QLabel   *F109ertuAddr,*F109softVer;
    QLineEdit *F109ertuAddrEdit,*F109softVerEdit;
    //设置参数布局
    //设置IP端口的参数布局
    void paramF3WidgetInit();
    void paramF3WidgetSet();
    void paramF3WidgetRead();
    void paramF3WidgetShow();
    QWidget  *  paramF3Widget;
    QGridLayout  *paramF3GridLayout;
    QLabel   *F3MainIP,*F3MainPort,*F3SecondIP,*F3SecondPort,*F3APN;
    QLineEdit *F3MainIPEdit,*F3MainPortEdit,*F3SecondIPEdit,*F3SecondPortEdit,*F3APNEdit;
    QPushButton*F3ParamRestore;
    //设置终端IP端口的参数布局
    void paramF7WidgetInit();
    void paramF7WidgetSet();
    void paramF7WidgetRead();
     void paramF7WidgetShow();
    QWidget  *  paramF7Widget;
    QGridLayout  *paramF7GridLayout;
    QLabel  *F7MainIP,*netMaskIP,*gatewayIP,*listenPort;
    QLineEdit  *F7MainIPEdit,*netMaskIPEdit,*gatewayIPEdit,*listemPortEdit;
    //设置F16 用户名 密码
    void paramF16WidgetInit();
    void paramF16WidgetSet();
    void paramF16WidgetRead();
    void paramF16WidgetShow();
    QWidget  *  paramF16Widget;
    QGridLayout  *paramF16GridLayout;
    QLabel  *F16UserName,*F16UserPassword;
    QLineEdit  *F16UserNameEdit,*F16UserPasswordEdit;

    //  F799GPRS 扩展信息  IMEI   ICCID
    void paramF799WidgetInit();
    void paramF799WidgetSet();
    void paramF799WidgetRead();
    void paramF799WidgetShow();
    QWidget  *  paramF799Widget;
    QGridLayout  *paramF799GridLayout;
    QLabel  *F799_IMEI,*F799_ICCID,*COUNTER_ADDR;
    QLineEdit  *F799_IMEI_Edit,*F799_ICCID_Edit,*COUNTER_ADDR_Edit;
    //设置报文监控开关 796 _  第16项
    void paramF796_16WidgetInit();
    void paramF796_16WidgetSet();
    void paramF796_16WidgetRead();
    void paramF796_16WidgetShow();
    QWidget  *  paramF796_16Widget;
    QGridLayout  *paramF796_16GridLayout;
    QLabel   *F796_16_FrameMonitor_description;
    QPushButton * F796_16_clear;
    QCheckBox *F796_16FrameMonitor_gprs,*F796_16FrameMonitor_meter,*F796_16_FrametoNet;


    //读取mes码 796 _  第24项
    void paramF796_24WidgetInit();
    void paramF796_24WidgetSet();
    void paramF796_24WidgetRead();
    void paramF796_24WidgetShow();
    QWidget  *  paramF796_24Widget;
    QGridLayout  *paramF796_24GridLayout;
    QLabel   *F796_24_mes;
    QLineEdit   *F796_24_mesEdit;

    //376协议的升级
    void Update376_WidgetInit();
    QWidget  *  Update376Widget;
    QGridLayout  *Update376GridLayout;
    QLabel   *Update376FilePathLabel;
    QPushButton *Update376FileButton;
    QLineEdit   *Update376FilePath_Edit;
    QPushButton   *Update376Start,*Update376End;
    QString fileName;
    QFile   updateFileHandler;
    INT8U   updateFile[512*1024];
    int   updateFileLen,file_total_seg,file_cur_seg;
    void  make_376update_frame();
     int timerUpdate,retransmitCnt,intoUpdateState; //10S 超时重发,重发3次。
     QProgressBar  *progressbar;

     //F803 设置多个IP和端口--厂站用的。
     void paramF803WidgetInit();
     void paramF803WidgetSet();
     void paramF803WidgetRead();
     void paramF803WidgetShow();
     QWidget  *  paramF803Widget;
     QGridLayout  *paramF803GridLayout;
     QLabel   *F803MainIP,*F803MainPort,*F803SecondIP,*F803SecondPort,*F803APN;
     QLineEdit *F803MainIPEdit,*F803MainPortEdit,*F803SecondIPEdit,*F803SecondPortEdit,*F803APNEdit;
      QPushButton*F803ParamRestore;
      //读取mes码 796 _  第182项
      void paramF796_182WidgetInit();
      void paramF796_182WidgetSet();
      void paramF796_182WidgetRead();
      void paramF796_182WidgetShow();
      QWidget  *  paramF796_182Widget;
      QGridLayout  *paramF796_182GridLayout;
      QLabel   *F796_182_MN;
      QLineEdit   *F796_182_MNEdit;
      //读取mes码 796 _  第1项
      void paramF796_1WidgetInit();
      void paramF796_1WidgetSet();
      void paramF796_1WidgetRead();
      void paramF796_1WidgetShow();
      QWidget  *  paramF796_1Widget;
      QGridLayout  *paramF796_1GridLayout;
      QLabel   *F796_1_ERTU_ADDR;
      QLineEdit   *F796_1_ERTU_ADDREdit;
      //读取mes码 796 _  第18_36项   ---电压（18）电流（36）倍率
      void paramF796_18_36WidgetInit();
      void paramF796_18_36WidgetSet();
      void paramF796_18_36WidgetRead();
      void paramF796_18_36WidgetShow();
      QWidget  *  paramF796_18_36Widget;
      QGridLayout  *paramF796_18_36GridLayout;
      QLabel   *F796_18_36Voltage,*F796_18_36Current;
      QLineEdit   *F796_18_36VoltageEdit,*F796_18_36CurrentEdit;
    //布局
    /*
    ________________________________
    |_______________________________|
    |                  |                               |
    |                  |                               |
    |                  |                               |
    |                  |                               |
    |                  |                               |
    |___________|___________________|
    */
    QHBoxLayout  *CtrlbuttonLayout;
    QHBoxLayout  *setItemLayout;
    QVBoxLayout  *setMainLayout;
};

#endif // PARAMSETANDREAD_H
